Tips&Tricks | I trucchi del mestiere |
![]() |
Come richiamare la finestra "Trova" del men∙ Start |
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ (ByVal hwnd As Long, ByVal lbOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, ByVal lpDirectory As String, _ ByVal nShowCmd as Long) Const SW_SHOW = 5 Private Sub CmdTrova_Click() ShellExecute Me.hWnd, "find", "c:\", vbNullString, SW_SHOW End Sub |
![]() |
Come ottenere info sulla Barra delle Applicazioni di Windows |
Const ABS_AUTOHIDE = &H1 Const ABS_ONTOP = &H2 Const ABM_GETSTATE = &H4 Const ABM_GETTASKBARPOS = &H5 Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type APPBARDATA cbSize As Long hwnd As Long uCallbackMessage As Long uEdge As Long rc As RECT lParam As Long End Type Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long Private Sub Form_Paint() Dim ABD As APPBARDATA, Ret As Long SHAppBarMessage ABM_GETTASKBARPOS, ABD Ret = SHAppBarMessage(ABM_GETSTATE, ABD) If (Ret And ABS_AUTOHIDE) Then Me.Print "L'opzione NASCONDI AUTOMATICAMENTE Φ attiva" If (Ret And ABS_ONTOP) Then Me.Print "l'opzione SEMPRE IN PRIMO PIANO Φ attiva" Me.Print "Le coordinate della barra delle applicazioni: (" + Trim(Str(ABD.rc.Left)) + "," + Trim(Str(ABD.rc.Top)) + ")-(" + Trim(Str(ABD.rc.Right)) + "," + Trim(Str(ABD.rc.Bottom)) + ")" End Sub |
![]() |
Come inviare una stringa di testo ad una shell DOS |
Private Sub Command1_Click() Shell ("command.com"), vbMaximizedFocus End Sub Private Sub Command2_Click() Clipboard.Clear Clipboard.SetText "Dir *.*" + Chr$(13) AppActivate "Prompt di MS-DOS" SendKeys "% ep", 1 End Sub |
![]() |
Come richiamare la finestra delle proprietα di un file |
Option Explicit Private Type SHELLEXECUTEINFO cbSize As Long fMask As Long hWnd As Long lpVerb As String lpFile As String lpParameters As String lpDirectory As String nShow As Long hInstApp As Long lpIDList As Long 'Optional; ignore lpClass As String 'Optional; ignore hkeyClass As Long 'Optional; ignore dwHotKey As Long 'Optional; ignore hIcon As Long 'Optional; ignore hProcess As Long 'Optional; ignore End Type Private Const SEE_MASK_INVOKEIDLIST = &HC Private Const SEE_MASK_NOCLOSEPROCESS = &H40 Private Const SEE_MASK_FLAG_NO_UI = &H400 Private Declare Function ShellExecuteEx Lib "shell32" Alias "ShellExecuteExA" (sei As SHELLEXECUTEINFO) As Long Private Sub ShowProperties(strFilename As String, hWnd As Long) Dim lngReturn As Long Dim sei As SHELLEXECUTEINFO With sei .cbSize = Len(sei) .fMask = SEE_MASK_NOCLOSEPROCESS Or SEE_MASK_INVOKEIDLIST Or SEE_MASK_FLAG_NO_UI .hWnd = hWnd .lpVerb = "properties" .lpFile = strFilename .lpParameters = vbNullChar .lpDirectory = vbNullChar .nShow = 0 .hInstApp = 0 .lpIDList = 0 End With lngReturn = ShellExecuteEx(sei) End Sub Private Sub Command1_Click() ShowProperties "c:\winnt\explorer.exe", Me.hWnd End Sub |
![]() |
Come invocare un report Access da Visual Basic |
Dim objAccess As Object Private Sub Command1_Click() Dim dbName As String Dim rptName As String Dim Preview As Long Const acNormal = 0 Const acPreview = 2 dbName = "prova.mdb" rptName = "Nome_Report" Preview = acPreview 'acNormal With objAccess .OpenCurrentDatabase filepath:=dbName If Preview = acPreview Then .Visible = True .DoCmd.OpenReport rptName, Preview Else .DoCmd.OpenReport rptName End If End With End Sub Private Sub Form_Load() Set objAccess = CreateObject("Access.Application") End Sub Private Sub Form_Unload(Cancel As Integer) On Error Resume Next objAccess.Quit On Error GoTo 0 Set objAccess = Nothing End Sub |